<template>
  <a-spin :spinning="spinning">
    <a-form-model
      ref="ruleForm"
      :model="form"
      :rules="rules"
      :label-col="labelCol"
      :wrapper-col="wrapperCol"
    >
      <a-row :gutter="15">
        <a-col :span="12">
          <a-form-model-item ref="name" label="名称" prop="name">
            <a-input v-model="form.name" />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="标识" prop="type">
            <a-input v-model="form.type" />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="备注" prop="remark">
            <a-input v-model="form.remark" type="textarea" />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="状态" prop="enable">
            <a-switch
              v-model="form.status"
              checked-children="正常"
              un-checked-children="停用"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-form-model-item :wrapper-col="{ span: 14 }">
        <a-button type="primary" @click="submit('ruleForm')">
          新增
        </a-button>
        <a-button style="margin-left: 10px;" @click="reset">
          重置
        </a-button>
      </a-form-model-item>
    </a-form-model>
  </a-spin>
</template>
<script>
import AddMixin from "@/mixins/basic/add.js";
export default {
  name: "add",
  mixins: [AddMixin],
  data() {
    return {
      saveUrl: "/system/dict/type/saveOne",
      form: {
        name: "",
        status: true,
        type: "",
        remark: "",
      },
      rules: {},
    };
  },
  methods: {
    formatData() {
      const form = JSON.parse(JSON.stringify(this.form));
      form.status = form.status ? 0 : -1;
      console.log(form);
      return form;
    },
  },
};
</script>
